package com.jingge.home.framework;

import com.jingge.home.util.LocalCacheManager;
import com.jingge.home.util.SpringUtil;

/**
 * 缓存Key常量
 *
 * @author Yongxiang
 * @date 2025-07-30 11:37
 * @email 1158055613@qq.com
 */
public class CacheKeyConstant {
	public static final String COMMAND_PREFIX = "c:";
	public static final String ADMIN_COMMAND_PREFIX = "a:";
	public static final String MORE_MSG_PREFIX = "@";
	public static final String AUTH_KEY_PREFIX = "home_wechat_auth:";
	public static final String CONVERSATION_ID_PREFIX = "user_conversation_id:";
	public static final String RECEIVE_MSG_ID_PREFIX = "receive_msg_id:";
	/**
	 * 重试次数
	 */
	public static final String RETRY_COUNT_PREFIX = "user_retry_count:";
	/**
	 * 管理员授权
	 */
	public static final String ADMIN_PREFIX = "admin:";
	/**
	 * 服务锁定
	 */
	public static final String LOCK_KEY = "lock_service";
	public static final String TEMPORARY_PWD = "temporary_pwd";
	/**
	 * 对话图片
	 */
	public static final String PIC_PREFIX = "pic:";
	public static final String TEMPORARY_EXPIRE_PER_AUTH_PREFIX = "temporary_pwd_ep";
	public static final String CURRENT_API_KEY = "current_api_key";

	public static final String MSG_ANSWER_FINISHED_PREFIX = "receive_msg_answer_finished:";

	public static final String CONVERSATION_IN_HANDLING_PREFIX = "msg_handling:";

	public static final String RECENT_MSG_ID_PREFIX = "user_recent_msg_id:";

	/**
	 * 判断当时是否已授权
	 *
	 * @param user 来自的用户
	 * @return boolean
	 * @author Yongxiang(* ^ ▽ ^ *)
	 * @date 2025/7/30 14:42
	 */
	@SuppressWarnings("unchecked")
	public static boolean withAuth(String user) {
		return SpringUtil.getNonnullBean(LocalCacheManager.class).exist(AUTH_KEY_PREFIX + user);
	}
}
